<template>
  <div class="dialog" v-show="visible">
    <div class="dialog-wrap">
      <div class="dialog-header">
          <slot name="header" />
          <button class="dialog-header-close" @click="handleClick">x</button>
      </div>
      <div class="dialog-body">
          <slot></slot>
      </div>
      <div class="dialog-footer">
          <slot name="footer"></slot>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Dialog",
  props:{
      visible:{
        type:Boolean,
        require:true
      }
  },
  methods:{
      handleClick(){
          this.$emit('update:visible',!this.visible)
      }
  }
};
</script>

<style lang="less" scoped>
.dialog {
//最外层
    position: absolute;
    left: 0;
    right: 0 ;
    top:0;
    bottom:0;
    background-color: rgba(0,0,0,.3);
    .dialog-wrap {
        position:absolute;
        left:50%;
        top: 50%;
        width:460 px;
        height: 130px;
        box-sizing: border-box;
        padding: 12px;
        transform: translate(-50%,-50%);
        background-color: #fff;
        .dialog-header {
            display: flex;
            justify-content: space-between;
            font-size: 18px;
            .dialog-header-close {
                border:none;
                background-color:transparent;
                cursor:pointer
            }
        }
        .dialog-body {
            text-align: center;
            font-size: 16px;
            padding: 10px;
        }
    }
}
</style>